All files / src/types security.ts

0% Statements 0/14
100% Branches 0/0
100% Functions 0/0
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128                                                                                                                                                                                                                                                               
export interface SecurityIncident {
  id: number;
  user_id?: number;
  username: string;
  incident_type: string;
  ip_address?: string;
  user_agent?: string;
  device_id?: string;
  details?: string;
  created_at: string;
}
 
export interface SecurityBan {
  id: number;
  user_id?: number;
  username: string;
  ban_type: string;
  ban_reason: string;
  ban_level: number;
  banned_at: string;
  expires_at?: string;
  is_active: boolean;
  created_by?: number;
}
 
export interface CreateSecurityBanRequest {
  user_id?: number;
  username: string;
  ban_type: string;
  ban_reason: string;
  ban_level: number;
  expires_at?: string;
  created_by?: number;
}
 
export interface SecurityFilters {
  incident_type?: string;
  username?: string;
  start_date?: string;
  end_date?: string;
  page?: number;
  limit?: number;
}
 
export interface SecurityIncidentsResponse {
  incidents: SecurityIncident[];
  total: number;
  page: number;
  limit: number;
  total_pages: number;
}
 
export interface SecurityBansResponse {
  bans: SecurityBan[];
  total: number;
  page: number;
  limit: number;
  total_pages: number;
}
 
export interface SecurityStatsResponse {
  total_incidents: number;
  incidents_today: number;
  active_bans: number;
  permanent_bans: number;
  incidents_by_type: IncidentTypeCount[];
  recent_incidents: SecurityIncident[];
}
 
export interface IncidentTypeCount {
  incident_type: string;
  count: number;
}
 
export interface UnbanUserRequest {
  reason: string;
}
 
export interface UserBanStatus {
  is_banned: boolean;
  ban?: SecurityBan;
}
 
// Constantes para tipos de incidentes
export const INCIDENT_TYPES = {
  BRUTE_FORCE: 'BRUTE_FORCE',
  SUSPICIOUS_ACTIVITY: 'SUSPICIOUS_ACTIVITY',
  MULTIPLE_DEVICES: 'MULTIPLE_DEVICES',
  TOKEN_MANIPULATION: 'TOKEN_MANIPULATION'} as const;
 
// Constantes para tipos de ban
export const BAN_TYPES = {
  TEMPORARY: 'TEMPORARY',
  PERMANENT: 'PERMANENT'} as const;
 
// Constantes para niveles de ban
export const BAN_LEVELS = {
  FIRST: 1,    // 20 minutos
  SECOND: 2,   // 72 horas
  PERMANENT: 3, // Permanente
} as const;
 
// Mapeo de tipos de incidentes a descripciones legibles
export const INCIDENT_TYPE_LABELS: Record<string, string> = {
  [INCIDENT_TYPES.BRUTE_FORCE]: 'Brute Force Attack',
  [INCIDENT_TYPES.SUSPICIOUS_ACTIVITY]: 'Suspicious Activity',
  [INCIDENT_TYPES.MULTIPLE_DEVICES]: 'Multiple Devices',
  [INCIDENT_TYPES.TOKEN_MANIPULATION]: 'Token Manipulation'};
 
// Mapeo de niveles de ban a descripciones
export const BAN_LEVEL_LABELS: Record<number, string> = {
  [BAN_LEVELS.FIRST]: 'Level 1 (20 minutes)',
  [BAN_LEVELS.SECOND]: 'Level 2 (72 hours)',
  [BAN_LEVELS.PERMANENT]: 'Level 3 (Permanent)'};
 
// Colores para diferentes tipos de incidentes
export const INCIDENT_TYPE_COLORS: Record<string, string> = {
  [INCIDENT_TYPES.BRUTE_FORCE]: 'text-orange-600',
  [INCIDENT_TYPES.SUSPICIOUS_ACTIVITY]: 'text-yellow-600',
  [INCIDENT_TYPES.MULTIPLE_DEVICES]: 'text-blue-600',
  [INCIDENT_TYPES.TOKEN_MANIPULATION]: 'text-purple-600'};
 
// Colores para niveles de ban
export const BAN_LEVEL_COLORS: Record<number, string> = {
  [BAN_LEVELS.FIRST]: 'text-yellow-600',
  [BAN_LEVELS.SECOND]: 'text-orange-600',
  [BAN_LEVELS.PERMANENT]: 'text-red-600'};